--
-- Author: shunguo.chen
-- Date: 2019-07-26 11:31:02
--
-- LastChampionPanel 上一次冠军panel
--

local AvatarFactory = app:getClass("AvatarFactory")

local ClassRef = app.mvc.createPanelClass(...)

--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node)
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--
function ClassRef:init(data)
    self.super.init(self, data)

end

-- info = PvpChallengeSeasonInfo
function ClassRef:refreshChallengeInfo(info)
    self._challengeInfo = info
    self._ui.tlt:setString(info:getTitle())
    self._ui.text_mode:setString(info:getSeasonStr())
    self._ui.text_date:setString(info:getDateStr())

    local championBaseInfo = info.championBaseInfo
    if championBaseInfo then
        self._ui.name:setString(championBaseInfo:getName())
    else
        self._ui.name:setString(L("lua_code_text_441"))
    end
    self:_refreshPlayer(championBaseInfo)
end

function ClassRef:_refreshPlayer(params)
    self._ui.Node_1:removeAllChildren()
    if params then
        local character = AvatarFactory.createHeroIgnoreMount(params)
        character:playAni({name = "mapidle"})
        self._ui.Node_1:addChild(character)
    end
end

return ClassRef
